<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>找出数组中所有重复出现的元素</title>
</head>

<body>
</body>

</html>
<script>
    //创建数组
    var arr = [1, 2, 3, 4, 4, 5, 5, 6, 6];
    //创建一个空数组，把重复出现的元素添加到里面
    var Arr = [];
    //遍历arr数组
    for (var i = 0; i < arr.length; i++) {
        for (var x = i + 1; x < arr.length; x++) {
            if (arr[i] === arr[x] && Arr.indexOf(arr[x] === -1)) {  //检查arr数组中重复的元素有没有等于-1
                //在arr数组末尾添加一个或多个数组
                Arr.push(arr[i]);
            }
        }
    }
    console.log(Arr);
</script>